package com.zhaojk.audio.controller;

import cn.hutool.extra.spring.SpringUtil;
import com.zhaojk.audio.domain.TrainingPlan;
import com.zhaojk.audio.entity.PromptTemplate;
import com.zhaojk.audio.mapper.PromptTemplateMapper;
import com.zhaojk.audio.service.PromptTemplateServiceImpl;
import com.zhaojk.audio.service.TrainingPlanServiceImpl;
import com.zhaojk.audio.util.TimeTrace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 训练计划
 * @author zhaojk
 */
@RestController
@RequestMapping("/api/plan")
public class TrainingPlanController {
    @Autowired
    private TrainingPlanServiceImpl trainingPlanService;
    @Autowired
    private PromptTemplateServiceImpl promptTemplateService;
    /**
     * @return
     */
    @PostMapping("/train/{sceneId}")
    @TimeTrace("训练计划")
    public ResponseEntity<TrainingPlan> train(@PathVariable("sceneId") String sceneId) {
        TrainingPlan plan = trainingPlanService.getTrainingPlan(sceneId);
        return new ResponseEntity<>(plan, HttpStatus.OK);
    }

    @PostMapping("/extendPrompt/{prompt}")
    @TimeTrace("获取template")
    public ResponseEntity extendPrompt(@PathVariable("prompt") String prompt, @PathVariable("translation") String translation) {
        return new ResponseEntity<>(promptTemplateService.extendPrompt(prompt, translation), HttpStatus.OK);
    }
}
